<template>
  <page-meta :root-font-size="$rootFontSize"></page-meta>
  <view>
    <cover-view
      class="fixed z-50 left-3 top-10 h-10 leading-9 items-center flex w-12 text-sm"
      @click="onBack()"
      >返回</cover-view
    >
    <!--聊天IM移动端-webview容器-->
    <web-view
      :src="imUrl"
      ref="webview"
      :webview-styles="{ top: webWTop, height: webWHeight }"
    ></web-view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      imUrl: 'http://www.yysyy.com:3333/', //线上生产
      //imUrl: 'http://192.168.10.42:8083/', //本地测试
      //imUrl: process.env.VUE_APP_IM,
      webWTop: uni.getSystemInfoSync().statusBarHeight,
      webWHeight:
        uni.getSystemInfoSync().screenHeight -
        uni.getSystemInfoSync().statusBarHeight,
    };
  },
  onUnload() {
    uni.offKeyboardHeightChange();
  },
  onLoad() {
    uni.onKeyboardHeightChange((res) => {
      if (res) {
        let currentWebview = this.$scope.$getAppWebview();
        var wv = currentWebview.children()[0];
        wv.setStyle({
          height:
            uni.getSystemInfoSync().screenHeight -
            uni.getSystemInfoSync().statusBarHeight -
            res.height,
        });
      }
    });
  },
  methods: {
    //返回上一页
    onBack() {
      uni.navigateBack();
    },
  },
};
</script>

<style></style>
